package com.tevintao.marketingsystem.task;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.tevintao.marketingsystem.log.LogManager;
import com.tevintao.marketingsystem.services.ViewOperation;
import com.tevintao.marketingsystem.xposted.HookWebView;
import com.tevintao.marketingsystem.xposted.WxTaskManger;


public class StatisticsFriendNumTaskProcess extends SetTaskExtra {
    private static StatisticsFriendNumTaskProcess ourInstance = new StatisticsFriendNumTaskProcess();

    public static StatisticsFriendNumTaskProcess getInstance() {
        return ourInstance;
    }

    private StatisticsFriendNumTaskProcess() {
    }


    @SuppressWarnings("ResourceType")
    @Override
    public boolean processView(String contextName, View v) {
//        if (WxTaskProcess.DEBUG_MODEL) {
//            v.getContext().sendBroadcast(new Intent(HookWebView.ACTION_GET_LAST_HTML));
//            Object htmlObj = getExtra(HookWebView.KEY_LAST_HTML);
//            if (null != htmlObj) {
//                String html = htmlObj.toString();
//                LogManager.getInstance().logE("ttw", html);
//            }
//        } else {
//            HookWebView.getInstance().loadHtml();
//            LogManager.getInstance().logInfo("mLastHtml = " + HookWebView.mLastHtml);
//        }

        if (WxUiViewConfig.MAIN_LAUNCH.equals(contextName)) {
            boolean inContact = WxUiViewConfig.inTab(v, WxUiViewConfig.TAB_CONTACTS);
            if (inContact) {
                LogManager.getInstance().logInfo("当前位于通讯按钮所在的列表");
                View listView = v.findViewById(2131624187);
                LogManager.getInstance().logInfo("listView = " + listView);
                if (null != listView && listView instanceof ListView) {
                    ListView list = (ListView) listView;
                    taskError(v.getContext(), WxTaskManger.TASK_SATE_SUCCESS, "" + (list.getCount() - 4));
                    if (WxUiViewConfig.MAIN_LAUNCH.equals(contextName)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }


}
